package org.gastomuito.client;

import com.google.gwt.event.dom.client.HasChangeHandlers;
import com.google.gwt.event.dom.client.HasClickHandlers;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HTMLPanel;
import com.google.gwt.user.client.ui.HasValue;
import com.google.gwt.user.client.ui.ListBox;
import com.google.gwt.user.client.ui.TextBox;

public class ReceitaPanel extends Composite implements
        ContaContabilController.ReceitaDisplay {

    private static final String HTML = "<div id=\"receitaPanel\">"
            + "<h3>Informe sua receita líquida</h3>" + "</p>"
            + "<p id=\"valor\">" + "<label>$</label>" + "</p>"
            + "<p id=\"repeticao\">" + "<label>por</label>" + "</p>"
            + "<p id=\"submit\">" + "</div>";

    private TextBox valorField;

    private ListBox repeticaoField;

    private Button adicionaReceitaButton;

    private HTMLPanel panel;

    public ReceitaPanel() {
        valorField = new TextBox();
        repeticaoField = new ListBox();
        adicionaReceitaButton = new Button("Adicionar");
        repeticaoField.addItem("mês");
        repeticaoField.addItem("semana");
        repeticaoField.addItem("ano");
        valorField.setFocus(true);
        panel = new HTMLPanel(HTML);
        panel.add(valorField, "valor");
        panel.add(repeticaoField, "repeticao");
        panel.add(adicionaReceitaButton, "submit");
        initWidget(panel);
    }

    @Override
    public HasValue<String> getValor() {
        return this.valorField;
    }

    @Override
    public HasChangeHandlers getRepeticao() {
        return this.repeticaoField;
    }

    @Override
    public HasClickHandlers getSubmit() {
        return this.adicionaReceitaButton;
    }

}
